package org.aplikator.client.rpc;

import java.util.logging.Level;
import java.util.logging.Logger;

import com.google.gwt.user.client.rpc.AsyncCallback;

public abstract class Callback<T extends Response> implements AsyncCallback<T> {

    protected static final Logger LOG = Logger.getLogger(Callback.class.getName());

    public void onFailure(Throwable caught) {
        // Show the RPC error message to the user
        LOG.log(Level.SEVERE, "Error in remote call", caught);
    }

    public void onSuccess(T response) {
        process(response);
    }

    protected abstract void process(T response);

}
